# 名称:Backdream
# 时间2022/12/27 11:39
# 好物社页面类


from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage

class ProductsPage(BasePage):
    """好物社页面类"""

    #定位器
    search_locator = (By.XPATH, "//android.widget.TextView[@text=\"大家都在搜“日日煮星厨菜肴”\"]")
    shopping_card_locator = (By.XPATH, "//android.widget.RelativeLayout[@resource-id=\"com.gfeng.daydaycook:id/rl_cart\"]/android.widget.ImageView[1]")
    product_first_locator = (By.XPATH, "//android.widget.TextView[@text=\"日日煮自热系列-鲍鱼佛跳墙捞饭\"]")
    shopping_card_jump_locator = (By.XPATH, "//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/mTitle\"]")


    #操作方法
    def search_click(self):
        self.find_element(self.search_locator).click()

    def shopping_card_click(self):
        self.find_element(self.shopping_card_locator).click()

    def product_first_click(self):
        self.find_element(self.product_first_locator).click()

    def get_shopping_jump_result(self):
        return self.find_element(self.shopping_card_jump_locator).text